package com.smart.context;

import com.smart.Car;
import com.smart.beanfactory.MyBeanPostProcessor;
import com.smart.beanfactory.MyInstantiationAwareBeanPostProcessor;
import org.springframework.beans.factory.annotation.Configurable;
import org.springframework.context.annotation.Bean;

/**
 * @author chenxingyu
 * @date 2019/8/26 10:52
 */
//表示是一个配置信息提供类
@Configurable
public class Beans {

    //定义一个Bean
    @Bean(name = "car", initMethod = "myInit", destroyMethod = "myDestroy")
    public Car builderCar() {
        Car car = new Car();
        car.setBrand("传祺cs4");
        car.setMaxSpeed(200);
        return car;
    }

    @Bean
    public MyBeanPostProcessor getMyBeanPostProcessor() {
        return new MyBeanPostProcessor();
    }

    @Bean
    public MyBeanFactoryPostProcessor getMyBeanFactoryPostProcessor() {
        return new MyBeanFactoryPostProcessor();
    }

    @Bean
    public MyInstantiationAwareBeanPostProcessor getMyInstantiationAwareBeanPostProcessor() {
        return new MyInstantiationAwareBeanPostProcessor();
    }
}
